<template>
  <a-card :bordered="false">

    <div>


      <a-table
        ref="table"
        size="middle"
        :scroll="{x:true}"
        bordered
        rowKey="id"
        :columns="columns"
        :dataSource="dataSource"
        :pagination="ipagination"
        :loading="loading"
        class="j-table-force-nowrap"
        @change="handleTableChange">

        <template slot="htmlSlot" slot-scope="text">
          <div v-html="text"></div>
        </template>
        <template slot="imgSlot" slot-scope="text,record">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无图片</span>
          <img v-else :src="getImgView(text)" :preview="record.id" height="25px" alt="" style="max-width:80px;font-size: 12px;font-style: italic;"/>
        </template>
        <template slot="fileSlot" slot-scope="text">
          <span v-if="!text" style="font-size: 12px;font-style: italic;">无文件</span>
          <a-button
            v-else
            :ghost="true"
            type="primary"
            icon="download"
            size="small"
            @click="downloadFile(text)">
            下载
          </a-button>
        </template>
        <span slot="status" slot-scope="text, record, index">
            <a-tag color="pink" v-if="text==0">待审核</a-tag>
            <a-tag color="#87d068" v-if="text==1" >通过</a-tag>
            <a-tag color="#e70a0a" v-if="text==2" >未通过</a-tag>
        </span>
        <span slot="action" slot-scope="text, record">

        </span>

      </a-table>
    </div>

  </a-card>
</template>

<script>

import '@/assets/less/TableExpand.less'
import { mixinDevice } from '@/utils/mixin'
import { JeecgListMixin } from '@/mixins/JeecgListMixin'
import { getAction } from '@api/manage'

export default {
  name: 'UserhomeAuthenticationList',
  mixins:[JeecgListMixin, mixinDevice],
  props: {
    userhomeId: {
      type: Number,
      default: ''
    },
  },
  components: {

  },
  data () {
    return {
      description: '实名认证管理页面',
      // 表头
      columns: [
        {
          title:'真实姓名',
          align:"center",
          dataIndex: 'realName'
        },
        {
          title:'身份证号码',
          align:"center",
          dataIndex: 'certNo'
        },
        {
          title:'认证电话',
          align:"center",
          dataIndex: 'phone'
        },
        {
          title:'身份证正面',
          align:"center",
          dataIndex: 'certBeforeUrl',
          scopedSlots: { customRender: 'imgSlot' }
        },
        {
          title:'身份证反面',
          align:"center",
          dataIndex: 'certAfterUrl',
          scopedSlots: { customRender: 'imgSlot' }
        },
        {
          title:'认证时间',
          align:"center",
          dataIndex: 'createTime',
          customRender:function (text) {
            return !text?"":(text.length>10?text.substr(0,10):text)
          }
        },
        {
          title:'状态',
          align:"center",
          dataIndex: 'status',
          scopedSlots: { customRender: 'status' }
        }
      ],
      url: {
        list: "/gongqiang/userhomeAuthentication/list",
      },
      dictOptions:{},
      superFieldList:[],
    }
  },
  created() {
    this.getSuperFieldList();
  },
  computed: {
    importExcelUrl: function(){
      return `${window._CONFIG['domianURL']}/${this.url.importExcelUrl}`;
    },
  },
  methods: {
    initDictConfig(){
    },
    loadData(arg) {
      if (!this.url.list) {
        this.$message.error("请设置url.list属性!")
        return
      }
      if (this.userhomeId == null || this.userhomeId == "") {
        return
      }
      this.queryParam.userhomeId = this.userhomeId;
      //加载数据 若传入参数1则加载第一页的内容
      if (arg === 1) {
        this.ipagination.current = 1;
      }
      var params = this.getQueryParams();//查询条件
      this.loading = true;
      getAction(this.url.list, params).then((res) => {
        if (res.success) {
          //update-begin---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
          this.dataSource = res.result.records || res.result;
          if (res.result.total) {
            this.ipagination.total = res.result.total;
          } else {
            this.ipagination.total = 0;
          }
          //update-end---author:zhangyafei    Date:20201118  for：适配不分页的数据列表------------
        } else {
          this.$message.warning(res.message)
        }
      }).finally(() => {
        this.loading = false
      })
    },
    getSuperFieldList(){
      let fieldList=[];
      fieldList.push({type:'string',value:'userhomeId',text:'一般用户id',dictCode:''})
      fieldList.push({type:'string',value:'realName',text:'真实姓名',dictCode:''})
      fieldList.push({type:'string',value:'certNo',text:'身份证号码',dictCode:''})
      fieldList.push({type:'string',value:'phone',text:'认证电话',dictCode:''})
      fieldList.push({type:'int',value:'status',text:'状态',dictCode:''})
      this.superFieldList = fieldList
    }
  }
}
</script>
<style scoped>
@import '~@assets/less/common.less';
</style>